<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8" />
    <title>添加</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta
      name="viewport"
      content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"
    />
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all" />
    <script src="/layuiadmin/layui/layui.js"></script>
  </head>
  <body style="background-color: #fff">
    <div class="layui-card">
      <div class="layui-card-body">
        <form
          class="layui-form"
          action=""
          class="layui-form layui-form-pane"
          lay-filter="layui-form-pane"
          id="sbumitForm"
        >
          <?php if($hide_parent != 1) {?>
          <div class="layui-form-item">
            <label class="layui-form-label">上级分类</label>
            <div class="layui-input-block">
              <select name="parent_id">
                <option value="">请选择</option>
                <?php foreach($replay_categorys as $key =>
                $value) {?>
                <option value="{$key}">{$value}</option>
                <?php }?>
              </select>
            </div>
          </div>
          <?php }?>

          <div class="layui-form-item">
            <label class="layui-form-label">分类名称</label>
            <div class="layui-input-block">
              <input
                type="text"
                name="name"
                value=""
                class="layui-input"
                placeholder="分类名称"
                autocomplete="off"
              />
            </div>
          </div>

          <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
              <input
                type="text"
                name="sort"
                value=""
                class="layui-input"
                placeholder="排序"
                autocomplete="off"
              />
            </div>
          </div>

          <div class="layui-form-item" style="margin-top: 35px">
            <div class="layui-input-block">
              <span
                class="layui-btn"
                lay-submit=""
                lay-filter="submitForm"
                style="width: 100%"
                >确认添加</span
              >
            </div>
          </div>
        </form>
      </div>
    </div>

    <script>
      layui.use(["form", "upload"], function () {
        $ = layui.jquery;
        var form = layui.form,
          layer = layui.layer,
          upload = layui.upload;
        form.on("submit(submitForm)", function (obj) {
          layer.confirm("确认要修改吗？", { icon: 6 }, function () {
            $.ajax({
              type: "POST", //请求方式
              url: "/admin/video/add_replay_category", //请求地址
              dataType: "json", //返回的数据类型
              data: $("#sbumitForm").serialize(), //数据
              //请求成功
              success: function (data) {
                if (data.code == 0) {
                  layer.msg(data.msg, { icon: 1, time: 2000 }, function () {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    window.parent.location.reload();
                  });
                } else {
                  layer.msg(data.msg, { icon: 2, time: 5000 });
                }
              },
            });
          });
          return false;
        });
      });
    </script>
  </body>
</html>
